package com.example.aviwriter;

public class AviWriter {
    private long avi; //avi指针

    static {
        System.loadLibrary("AviWriterLib");
    }

    public void OpenOutFileByPath(String fileName){
        avi = OpenOutFile(fileName);
    }

    public void AviSetVideo(int width, int height, double fps, byte[] compressor){
        AviSetVideo(avi,width,height,fps,compressor);
    }

    public void AviSetAudio(int channels, long rate, int bits, int format, long mp3rate){
        AviSetAudio(avi,channels,rate,bits,format,mp3rate);
    }

    public int AviWriteVideo(byte[] data, long bytes, int keyframe){
       return  AviWriteVideo(avi,data,bytes,keyframe);
    }

    public int AviWriteAudio(byte[] data, long bytes){
      return   AviWriteAudio(avi,data,bytes);
    }

    public void AviClose(){
        AviClose(avi);
    }

    private native long OpenOutFile(String fileName);
    private native void AviSetVideo(long AVI,int width, int height, double fps, byte[] compressor);
    private native void AviSetAudio(long AVI, int channels, long rate, int bits, int format, long mp3rate);
    private native int  AviWriteVideo(long AVI, byte[] data, long bytes, int keyframe);
    private native int  AviWriteAudio(long AVI, byte[] data, long bytes);
    private native void AviClose(long AVI);
}
